% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Replication "Deconstructing the Yield Curve"
% Crump and Gospodinov (2024)
% Date: 26-JUL-2024
% Code to make csv file for Table 9
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clear all;
clc;

fullSampleBR = load('../output/BR_IndMats_B5000_BRdata0_rstarCPI1_197104_201801');

bootstrapFullSample = strings(15,7);
boostrapBRsubsample = strings(15,7);
bootstrapFullSample(:,1) = ["2-yr", "3-yr", "4-yr", "5-yr", "6-yr", "7-yr", "8-yr", "9-yr", "10-yr", "11-yr", "12-yr", "13-yr", "14-yr", "15-yr", "Avg."];
boostrapBRsubsample(:,1) = ["2-yr", "3-yr", "4-yr", "5-yr", "6-yr", "7-yr", "8-yr", "9-yr", "10-yr", "11-yr", "12-yr", "13-yr", "14-yr", "15-yr", "Avg."];
%
dispPref = '%3.2f';
%
bootstrapFullSample(:,2) = num2str(round(fullSampleBR.pval1_CPo(end,:)',2),dispPref);
bootstrapFullSample(:,3) = num2str(round(fullSampleBR.pval2_CPo(end-1,:)',2),dispPref);
bootstrapFullSample(:,4) = num2str(round(fullSampleBR.pval2_CPo(end,:)',2),dispPref);
%
bootstrapFullSample(:,5) = num2str(round(fullSampleBR.pval41_CPo(end,:)',2),dispPref);
bootstrapFullSample(:,6) = num2str(round(fullSampleBR.pval42_CPo(end-1,:)',2),dispPref);
bootstrapFullSample(:,7) = num2str(round(fullSampleBR.pval42_CPo(end,:)',2),dispPref);
%
boostrapBRsubsample(:,2) = num2str(round(fullSampleBR.pval1_sub_CPo(end,:)',2),dispPref);
boostrapBRsubsample(:,3) = num2str(round(fullSampleBR.pval2_sub_CPo(end-1,:)',2),dispPref);
boostrapBRsubsample(:,4) = num2str(round(fullSampleBR.pval2_sub_CPo(end,:)',2),dispPref);
%
boostrapBRsubsample(:,5) = num2str(round(fullSampleBR.pval41_sub_CPo(end,:)',2),dispPref);
boostrapBRsubsample(:,6) = num2str(round(fullSampleBR.pval42_sub_CPo(end-1,:)',2),dispPref);
boostrapBRsubsample(:,7) = num2str(round(fullSampleBR.pval42_sub_CPo(end,:)',2),dispPref);
%
writematrix([bootstrapFullSample boostrapBRsubsample(:,2:end)], '../output/bootstrapTableBR_IndMats.csv');

